package com.os.opencv.java.chapter3;

import org.opencv.core.*;
import org.opencv.highgui.HighGui;
import org.opencv.imgproc.Imgproc;

public class Draw {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //用于画图的背景图，尺寸为800x800
        Mat img = Mat.zeros(800, 800, CvType.CV_8UC3);
        Scalar white = new Scalar(255, 255, 255);
        //格子大小
        int size = 40;

        //画出围棋棋盘格子
        for(int i=0; i<19; i++) {
            Imgproc.line(img, new Point(40, 40 + size * i), new Point(760, 40 + size * i), white, 1);
            Imgproc.line(img, new Point(40 + size * i, 40), new Point(40 + size * i, 760), white, 1);
        }
        //画出棋盘的外框
        Imgproc.rectangle(img, new Point(30, 30), new Point(770, 770), white, 2);
        //画星位
        for(int i=3; i<19; i=i+6){
            for(int j=3; j<19; j=j+6){
                Imgproc.circle(img, new Point(40+size*i, 40+size*j), 4, white, 1);
            }
        }

        //在屏幕上显示画好的棋盘
        HighGui.imshow("img", img);
        HighGui.waitKey(0);
        System.exit(0);

    }
}
